<?php
/**
 * AccountsList.php
 * @author Winbeek <winbeek@gmail.com>
 * @since 21 July 2012
 * @version $Id: AccountsList.php 26 2012-07-28 17:47:11Z winbeek $
 */

final class AccountsList extends Nette\Application\UI\Control
{
	/** @var Nette\Database\Table\Selection $accounts */
	private $accounts;


	/**
	 * @param Nette\Database\Table\Selection $accounts
	 */
	public function __construct(Nette\Database\Table\Selection $accounts)
	{
		$this->accounts = $accounts;
	}

	public function render()
	{
		$this->template->accounts = $this->accounts;

		$this->template->setFile(__DIR__ . '/AccountsList.latte');
		$this->template->render();
	}

	protected function createComponentAccount()
	{
		$accounts = $this->accounts;
		return new Nette\Application\UI\Multiplier(function ($accountId) use ($accounts) {
			return new Account($accounts[$accountId]);
		});
	}
}
